cmake_minimum_required(VERSION 3.18 FATAL_ERROR)
project(libtorch_test)

set(TORCH_BUILD_DIR "$ENV{HOME}/codes_build/pytorch/build")

include_directories(${TORCH_BUILD_DIR}
	${TORCH_BUILD_DIR}/../torch/csrc/api/include
	${TORCH_BUILD_DIR}/..
	${TORCH_BUILD_DIR}/../aten/src
	${TORCH_BUILD_DIR}/../build/aten/src
)

set(LIBS "${TORCH_BUILD_DIR}/lib/libc10.so"
	"${TORCH_BUILD_DIR}/lib/libtorch.so"
	"${TORCH_BUILD_DIR}/lib/libtorch_cpu.so"
)

message("TORCH_BUILD_DIR=${TORCH_BUILD_DIR}")
message("LIBS=${LIBS}")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")

add_executable(hello hello.cpp)
target_link_libraries(hello "${LIBS}")

add_executable(test test.cpp)
target_link_libraries(test "${LIBS}")

add_executable(backward backward.cpp)
target_link_libraries(backward "${LIBS}")

# add_executable(sentiment_analysis sentiment_analysis.cpp)
# target_link_libraries(sentiment_analysis "${LIBS}")

set_property(TARGET test PROPERTY CXX_STANDARD 17)
